home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / perf_harness / TORUS.C < prev   
Encoding:
C/C++ Source or Header  |  1998-08-12  |  1.6 KB  |  62 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1996. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <string.h>
  9. #include <GL/glut.h>
  10.  
  11. /* Modify these variables if necessary to control the number of
  12.    iterations for per time sample, the GLUT display mode for the
  13.    window, and the minimum test running time in seconds. */
  14. extern int testIterationsStep, testDisplayMode, testMinimumTestTime;
  15.  
  16. void
  17. testInit(int argc, char **argv, int width, int height)
  18. {
  19.   static GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0};
  20.   static GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
  21.   int solid, i;
  22.  
  23.   glViewport(0, 0, width, height);
  24.   glMatrixMode(GL_PROJECTION);
  25.   gluPerspective(25.0, width/height, 1.0, 10.0);
  26.   glMatrixMode(GL_MODELVIEW);
  27.   gluLookAt(0.0, 0.0, 5.0,
  28.     0.0, 0.0, 0.0,
  29.     0.0, 1.0, 0.);
  30.   glTranslatef(0.0, 0.0, -1.0);
  31.  
  32.   glColor3f(1.0, 0.0, 0.0);
  33.   glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  34.   glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  35.  
  36.   solid = 1;
  37.   for (i = 1; i < argc; i++) {
  38.     if (!strcmp("-light", argv[i])) {
  39.       glEnable(GL_LIGHTING);
  40.       glEnable(GL_LIGHT0);
  41.     } else if (!strcmp("-depth", argv[i])) {
  42.       glEnable(GL_DEPTH_TEST);
  43.     } else if (!strcmp("-wire", argv[i])) {
  44.       solid = 0;
  45.     }
  46.   }
  47.   glNewList(1, GL_COMPILE);
  48.   if (solid) {
  49.     glutSolidTorus(0.25, 0.75, 100, 100);
  50.   } else {
  51.     glutWireTorus(0.25, 0.75, 100, 100);
  52.   }
  53.   glEndList();
  54. }
  55.  
  56. void
  57. testRender(void)
  58. {
  59.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  60.   glCallList(1);
  61. }
  62.